Public Class ResultadosSensor
    Dim mID As Integer
    Dim mIDSensor As Integer
    Dim mFecha As Date
    Dim mHora As Date
    Dim mValor As Double
    Dim mIDEstanque As Integer
    Dim mIDEspecie As Integer
    Dim mValorMaximo As Double
    Dim mValorMinimo As Double
    Dim mMensaje As String

    Property ValorMinimo() As Double
        Get
            Return mValorMinimo
        End Get
        Set(ByVal value As Double)
            mValorMinimo = value
        End Set
    End Property
    Property ValorMaximo() As Double
        Get
            Return mValorMaximo
        End Get
        Set(ByVal value As Double)
            mValorMaximo = value
        End Set
    End Property

    Property Estanque() As Integer
        Get
            Return mIDEstanque
        End Get
        Set(ByVal value As Integer)
            mIDEstanque = value
        End Set
    End Property

    Property Especie() As Integer
        Get
            Return mIDEspecie
        End Get
        Set(ByVal value As Integer)
            mIDEspecie = value
        End Set
    End Property
    Property ID() As Integer
        Get
            Return mID
        End Get
        Set(ByVal Value As Integer)
            mID = Value
        End Set
    End Property

    Property IDSensor() As Integer
        Get
            Return mIDSensor
        End Get
        Set(ByVal Value As Integer)
            mIDSensor = Value
        End Set
    End Property

    Property Fecha() As DateTime
        Get
            Return mFecha
        End Get
        Set(ByVal Value As DateTime)
            mFecha = Value
        End Set
    End Property

    Property Hora() As Date
        Get
            Return mHora
        End Get
        Set(ByVal Value As Date)
            mHora = Value
        End Set
    End Property

    Property Valor() As Double
        Get
            Return mValor
        End Get
        Set(ByVal Value As Double)
            mValor = Value
        End Set
    End Property

    Property Mensaje() As String
        Get
            Return mMensaje
        End Get
        Set(ByVal Value As String)
            mMensaje = Value
        End Set
    End Property

    Public Function Nuevo() As Boolean
        Dim oSQL As DataAccessTecnoPez.SQL
        Dim strSQL As String

        Dim valorEspecie As String
        valorEspecie = IIf(Me.Especie > 0, Me.Especie, "NULL")
        strSQL = "INSERT INTO ResultadosSensor (IDSensor, Fecha,  Valor, IDEstanque, IDEspecie, ValorMaximo, ValorMinimo)" _
                & " VALUES (" & Me.IDSensor & ", " & "?" & ", " & Me.Valor & ", " & Me.Estanque & ", " & valorEspecie & ", " & Me.ValorMaximo & ", " & Me.ValorMinimo & ")"

        oSQL = New DataAccessTecnoPez.SQL
        If oSQL.IsConnected = True Then
            oSQL.SqlString = strSQL
            If oSQL.ExecuteNonQuery(Me.Fecha) > 0 Then
                oSQL.Close()
                Return True
            Else
                oSQL.Close()
                Me.Mensaje = "No se pudo registrar el resultado, " '& oSQL.getMensaje
                Return False
            End If
        Else
            oSQL.Close()
            Return False
        End If
    End Function

End Class
